﻿using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ICSharpCode.CodeCompletion
{
    /// <summary>
    /// This interface allows to provide more information for scripts such as using statements, etc.
    /// </summary>
    public interface ICSharpScriptProvider
    {
        /// <summary>
        /// Options file
        /// </summary>
        CompilerOptions Options { get; }

        /// <summary>
        /// The length of code added in the begining of the code when call <see cref="GenerateCodeFromCSX"/>
        /// </summary>
        int OffSet { get; }

        /// <summary>
        /// Get the usings used in the code.
        /// </summary>
        string GetUsing();

        /// <summary>
        /// 
        /// </summary>
        string GetVars();

        /// <summary>
        /// Get the assemblies used in the file
        /// </summary>
        string[] GetAssemblies();

        /// <summary>
        /// Get the names used in the file usings
        /// </summary>
        string GetNamespacesUsed();

        /// <summary>
        /// Opens a file, reads the json options and the code
        /// </summary>
        /// <param name="file">The fisical file name.</param>
        void ReadOptionsFile(string file);

        /// <summary>
        /// Generate code ready to compile, adding usings, class name and main method.
        /// </summary>
        /// <param name="code">script content with no main method, this is the code that on screen.</param>
        string GenerateCodeFromCSX(string code);

        /// <summary>
        /// Generate code to feed the formater engine
        /// </summary>
        /// <param name="code">The code to format</param>
        string GenerateCodeForFormating(string code);

        /// <summary>
        /// Removes the needed code added to the formater code engine
        /// </summary>
        /// <param name="formatedCode">The code formated</param>
        string ReadFromFormatedCode(string formatedCode);

        /// <summary>
        /// Compile the code in editor
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        CompilerResults Compile(string code);

        /// <summary>
        /// Executes the code in editor.
        /// </summary>
        /// <param name="results"></param>
        void RunCode(CompilerResults results);

        /// <summary>
        /// Saves the code with the options
        /// </summary>
        void Save(string location, string code);

        /// <summary>
        /// Modify the usings used in the code file
        /// </summary>
        /// <param name="usings">A string with all usings names, one on each line.</param>
        void AlterUsings(string usings);

        /// <summary>
        /// Modify the references used in the code file
        /// </summary>
        /// <param name="references">All the references (full path) used in the file.</param>
        void AlterReferences(string[] references);

        /// <summary>
        /// Save the options in the file, using the json format.
        /// </summary>
        void SaveOptions();
    }
}
